package com.lvdp.controller;


import com.lvdp.dto.Result;
import com.lvdp.service.IFollowService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 *
 * @author 辉哥
 * @since 2022-11-29
 */
@RestController
@RequestMapping("/follow")
public class FollowController {

    @Resource
    private IFollowService followService;

    /**
     * 关注接口
     * @param id 要关注的用户id
     * @param isFollow 关注或者取关
     * @return 结果
     */
    @PutMapping("/{id}/{isFollow}")
    public Result follow(@PathVariable("id")Long id, @PathVariable("isFollow")Boolean isFollow) {
        return followService.follow(id, isFollow);
    }

    /**
     * 是否关注
     * @param id 进入的id
     * @return 是否关注
     */
    @GetMapping("/or/not/{id}")
    public Result isFollow(@PathVariable("id")Long id) {
        return followService.isFollow(id);
    }

    /**
     * 获取当前登录人和目标用户共同关注人
     * @param id 目标用户
     * @return 共同关注
     */
    @GetMapping("/common/{id}")
    public Result followCommons(@PathVariable("id")Long id) {
        return followService.followCommons(id);
    }

}
